<?php
/**
 * Created by PhpStorm.
 * User: VMU
 * Date: 2017/3/6
 * Time: 18:35
 */

namespace App\Channels;


use App\Services\MlSms;
use App\Services\RlySms;
use App\Sms\Contracts\Sms;
use Illuminate\Notifications\Notification;

class SmsChannel
{
    private $sms;
    public function __construct(Sms $sms)
    {
        $this->sms = $sms;
    }

    /**
     * 短信发送通道
     * @param $notifiable
     * @param Notification $notification
     */
    public function send($notifiable, Notification $notification)
    {
        $message = $notification->toSms($notifiable);        

        if($message['phone'] && !env('APP_DEBUG')) {

            $rt = $this->sms->sendSms($message['phone'],$message['content']);
            if($rt) {
                return true;
            } else {
                return false;
            }
        }
    }
}